using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class VendMap : EntityTypeConfiguration<Vend>
    {
        public VendMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.ID)
                .IsRequired()
                .HasMaxLength(6);

            this.Property(t => t.VENDSRH)
                .HasMaxLength(6);

            this.Property(t => t.COMPANY)
                .HasMaxLength(50);

            this.Property(t => t.ADDR1)
                .HasMaxLength(35);

            this.Property(t => t.ADDR2)
                .HasMaxLength(35);

            this.Property(t => t.CITY)
                .HasMaxLength(21);

            this.Property(t => t.STATE)
                .HasMaxLength(3);

            this.Property(t => t.ZIP)
                .HasMaxLength(14);

            this.Property(t => t.FEDID)
                .HasMaxLength(11);

            this.Property(t => t.CONTACT)
                .HasMaxLength(30);

            this.Property(t => t.PHONE)
                .HasMaxLength(40);

            this.Property(t => t.FAX)
                .HasMaxLength(12);

            this.Property(t => t.ACCT)
                .HasMaxLength(40);

            this.Property(t => t.APACCT)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.DESC)
                .HasMaxLength(30);

            this.Property(t => t.LICENSE_NO)
                .HasMaxLength(15);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            this.Property(t => t.sunfrom1)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.sunto1)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.sunfrom2)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.sunto2)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.sunfrom3)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.sunto3)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.monfrom1)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.monto1)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.monfrom2)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.monto2)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.monfrom3)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.monto3)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.tuefrom1)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.tueto1)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.tuefrom2)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.tueto2)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.tuefrom3)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.tueto3)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.wedfrom1)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.wedto1)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.wedfrom2)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.wedto2)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.wedfrom3)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.wedto3)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.thufrom1)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.thuto1)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.thufrom2)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.thuto2)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.thufrom3)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.thuto3)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.frifrom1)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.frito1)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.frifrom2)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.frito2)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.frifrom3)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.frito3)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.satfrom1)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.satto1)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.satfrom2)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.satto2)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.satfrom3)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.satto3)
                .IsFixedLength()
                .HasMaxLength(8);

            this.Property(t => t.code)
                .IsFixedLength()
                .HasMaxLength(2);

            this.Property(t => t.ANumber)
                .IsFixedLength()
                .HasMaxLength(3);

            this.Property(t => t.under_collection_acct)
                .HasMaxLength(40);

            this.Property(t => t.UID)
                .HasMaxLength(50);

            this.Property(t => t.Vend_ItemPrefix)
                .HasMaxLength(10);

            this.Property(t => t.Vend_Reference)
                .HasMaxLength(20);

            this.Property(t => t.Vend_RecordType)
                .HasMaxLength(20);

            this.Property(t => t.Vend_RecordID)
                .HasMaxLength(20);

            // Table & Column Mappings
            this.ToTable("Vend");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.VENDSRH).HasColumnName("VENDSRH");
            this.Property(t => t.COMPANY).HasColumnName("COMPANY");
            this.Property(t => t.ADDR1).HasColumnName("ADDR1");
            this.Property(t => t.ADDR2).HasColumnName("ADDR2");
            this.Property(t => t.CITY).HasColumnName("CITY");
            this.Property(t => t.STATE).HasColumnName("STATE");
            this.Property(t => t.ZIP).HasColumnName("ZIP");
            this.Property(t => t.FEDID).HasColumnName("FEDID");
            this.Property(t => t.CONTACT).HasColumnName("CONTACT");
            this.Property(t => t.PHONE).HasColumnName("PHONE");
            this.Property(t => t.ISSUE1099).HasColumnName("ISSUE1099");
            this.Property(t => t.ONETIME).HasColumnName("ONETIME");
            this.Property(t => t.FAX).HasColumnName("FAX");
            this.Property(t => t.ACCT).HasColumnName("ACCT");
            this.Property(t => t.CURRENCY).HasColumnName("CURRENCY");
            this.Property(t => t.APACCT).HasColumnName("APACCT");
            this.Property(t => t.OUTPATIENT).HasColumnName("OUTPATIENT");
            this.Property(t => t.DESC).HasColumnName("DESC");
            this.Property(t => t.TYPE).HasColumnName("TYPE");
            this.Property(t => t.PYMT_TERMS).HasColumnName("PYMT_TERMS");
            this.Property(t => t.SPECIALTY).HasColumnName("SPECIALTY");
            this.Property(t => t.LICENSE_NO).HasColumnName("LICENSE_NO");
            this.Property(t => t.STAFFTYPE).HasColumnName("STAFFTYPE");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.VendDate).HasColumnName("VendDate");
            this.Property(t => t.ISMASTER).HasColumnName("ISMASTER");
            this.Property(t => t.sunfrom1).HasColumnName("sunfrom1");
            this.Property(t => t.sunto1).HasColumnName("sunto1");
            this.Property(t => t.sunfrom2).HasColumnName("sunfrom2");
            this.Property(t => t.sunto2).HasColumnName("sunto2");
            this.Property(t => t.sunfrom3).HasColumnName("sunfrom3");
            this.Property(t => t.sunto3).HasColumnName("sunto3");
            this.Property(t => t.monfrom1).HasColumnName("monfrom1");
            this.Property(t => t.monto1).HasColumnName("monto1");
            this.Property(t => t.monfrom2).HasColumnName("monfrom2");
            this.Property(t => t.monto2).HasColumnName("monto2");
            this.Property(t => t.monfrom3).HasColumnName("monfrom3");
            this.Property(t => t.monto3).HasColumnName("monto3");
            this.Property(t => t.tuefrom1).HasColumnName("tuefrom1");
            this.Property(t => t.tueto1).HasColumnName("tueto1");
            this.Property(t => t.tuefrom2).HasColumnName("tuefrom2");
            this.Property(t => t.tueto2).HasColumnName("tueto2");
            this.Property(t => t.tuefrom3).HasColumnName("tuefrom3");
            this.Property(t => t.tueto3).HasColumnName("tueto3");
            this.Property(t => t.wedfrom1).HasColumnName("wedfrom1");
            this.Property(t => t.wedto1).HasColumnName("wedto1");
            this.Property(t => t.wedfrom2).HasColumnName("wedfrom2");
            this.Property(t => t.wedto2).HasColumnName("wedto2");
            this.Property(t => t.wedfrom3).HasColumnName("wedfrom3");
            this.Property(t => t.wedto3).HasColumnName("wedto3");
            this.Property(t => t.thufrom1).HasColumnName("thufrom1");
            this.Property(t => t.thuto1).HasColumnName("thuto1");
            this.Property(t => t.thufrom2).HasColumnName("thufrom2");
            this.Property(t => t.thuto2).HasColumnName("thuto2");
            this.Property(t => t.thufrom3).HasColumnName("thufrom3");
            this.Property(t => t.thuto3).HasColumnName("thuto3");
            this.Property(t => t.frifrom1).HasColumnName("frifrom1");
            this.Property(t => t.frito1).HasColumnName("frito1");
            this.Property(t => t.frifrom2).HasColumnName("frifrom2");
            this.Property(t => t.frito2).HasColumnName("frito2");
            this.Property(t => t.frifrom3).HasColumnName("frifrom3");
            this.Property(t => t.frito3).HasColumnName("frito3");
            this.Property(t => t.satfrom1).HasColumnName("satfrom1");
            this.Property(t => t.satto1).HasColumnName("satto1");
            this.Property(t => t.satfrom2).HasColumnName("satfrom2");
            this.Property(t => t.satto2).HasColumnName("satto2");
            this.Property(t => t.satfrom3).HasColumnName("satfrom3");
            this.Property(t => t.satto3).HasColumnName("satto3");
            this.Property(t => t.notes).HasColumnName("notes");
            this.Property(t => t.CreationDate).HasColumnName("CreationDate");
            this.Property(t => t.ServicePerc).HasColumnName("ServicePerc");
            this.Property(t => t.Lastupdate).HasColumnName("Lastupdate");
            this.Property(t => t.code).HasColumnName("code");
            this.Property(t => t.ANumber).HasColumnName("ANumber");
            this.Property(t => t.enablevat).HasColumnName("enablevat");
            this.Property(t => t.CSTCTRID).HasColumnName("CSTCTRID");
            this.Property(t => t.under_collection_acct).HasColumnName("under_collection_acct");
            this.Property(t => t.secondspeciality).HasColumnName("secondspeciality");
            this.Property(t => t.IID).HasColumnName("IID");
            this.Property(t => t.MasterID).HasColumnName("MasterID");
            this.Property(t => t.FeesPlan).HasColumnName("FeesPlan");
            this.Property(t => t.TPI).HasColumnName("TPI");
            this.Property(t => t.UID).HasColumnName("UID");
            this.Property(t => t.ExternalParty).HasColumnName("ExternalParty");
            this.Property(t => t.RefFeesplan).HasColumnName("RefFeesplan");
            this.Property(t => t.MonthlyTarget).HasColumnName("MonthlyTarget");
            this.Property(t => t.VND_Physio).HasColumnName("VND_Physio");
            this.Property(t => t.Vend_AcctAssigned).HasColumnName("Vend_AcctAssigned");
            this.Property(t => t.Vend_ItemPrefix).HasColumnName("Vend_ItemPrefix");
            this.Property(t => t.Vend_Reference).HasColumnName("Vend_Reference");
            this.Property(t => t.Vend_RecordType).HasColumnName("Vend_RecordType");
            this.Property(t => t.Vend_RecordID).HasColumnName("Vend_RecordID");
            this.Property(t => t.Vnd_Department).HasColumnName("Vnd_Department");

            // Relationships
            this.HasOptional(t => t.Acct1)
                .WithMany(t => t.Vends)
                .HasForeignKey(d => d.ACCT);
            this.HasRequired(t => t.Acct2)
                .WithMany(t => t.Vends1)
                .HasForeignKey(d => d.APACCT);
            this.HasOptional(t => t.Acct3)
                .WithMany(t => t.Vends2)
                .HasForeignKey(d => d.under_collection_acct);
            this.HasOptional(t => t.currency1)
                .WithMany(t => t.Vends)
                .HasForeignKey(d => d.CURRENCY);
            this.HasOptional(t => t.Specialty1)
                .WithMany(t => t.Vends)
                .HasForeignKey(d => d.SPECIALTY);

        }
    }
}
